/*
后台入口文件
*/
var router=require('express').Router();

//判断登录状态
router.use(function(req,res,next){

    if(req.url=='/login' || req.url=='/login/doLogin'){
        next();
    }else{

        if(req.session.userinfo&&req.session.userinfo.username!=''){
            req.app.locals['userinfo']=req.session.userinfo; 
            next();
        }else{
            res.redirect('/admin/login')
        }
    }

})


//引入控制器模块
var index=require('./admin/index.js');
var login=require('./admin/login.js');

//根据路由加载对应的控制器
router.use('/',index);
router.use('/index',index);
router.use('/login',login);

module.exports = router;